/* Copyright (c) 2025 Beijing Semidrive Technology Corporation
 * SPDX-License-Identifier: Apache-2.0
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/** *****************************************************************************************************
 *  \file     Mcal_ASM.h                                                                               *
 *  \brief    Cache opeartions.                                                                         *
 *                                                                                                      *
 * <table>                                                                                              *
 * <tr><th>Date           <th>Version                                                                   *
 * <tr><td>2023/07/17     <td>1.0.0                                                                     *
 * </table>                                                                                             *
 *******************************************************************************************************/
#ifndef MCAL_ASM_H
#define MCAL_ASM_H
/********************************************************************************************************
 *                                      Include header files                                            *
 *******************************************************************************************************/
#if !defined(ASSEMBLY)
#include <Mcal.h>
#endif /* #if !defined(ASSEMBLY) */
/********************************************************************************************************
 *                                 Global Macro definition                                              *
 *******************************************************************************************************/
#if !defined(ASSEMBLY)
/********************************************************************************************************
 *                                  Global Function Declarations                                        *
 *******************************************************************************************************/
/** *****************************************************************************************************
 * \brief This function provide an security mechanism for enable i-cache or d-cache
 *
 * \verbatim
 * Syntax             : Mcal_ArchEnableCache
 *
 * Service ID[hex]    : None
 *
 * Sync/Async         : Synchronous
 *
 * Reentrancy         : Non Reentrant
 *
 * Parameters (in)    : flags - define the cache which should be enable.
 *
 * Parameters (inout) : None
 *
 * Parameters (out)   : None
 *
 * Return value       : None
 *
 * Description        : Provide an security mechanism enable i-cache and d-cache, before d-cache
 *                      or d-cache enable, disable, cache line should be invalidate.
 * \endverbatim
 * Traceability       : SWSR SWSR_LIB_003
 *******************************************************************************************************/
extern void Mcal_ArchEnableCache(uint32 flags);
/** *****************************************************************************************************
 * \brief This function provide an security mechanism for disable i-cache or d-cache
 *
 * \verbatim
 * Syntax             : Mcal_ArchDisableCache
 *
 * Service ID[hex]    : None
 *
 * Sync/Async         : Synchronous
 *
 * Reentrancy         : Non Reentrant
 *
 * Parameters (in)    : flags - define the cache which should be disbale.
 *
 * Parameters (inout) : None
 *
 * Parameters (out)   : None
 *
 * Return value       : None
 *
 * Description        : Provide an security mechanism disable i-cache and d-cache, before d-cache
 *                      disable, it should be clean and invalidate all cache line. after i-cache
 *                      disable, invalidate all cache line.
 * \endverbatim
 * Traceability       : SWSR SWSR_LIB_004
 *******************************************************************************************************/
extern void Mcal_ArchDisableCache(uint32 flags);
/** *****************************************************************************************************
 * \brief This function use for read the d-cache status.
 *
 * \verbatim
 * Syntax             : Mcal_ArchRdSctlr
 *
 * Service ID[hex]    : None
 *
 * Sync/Async         : Synchronous
 *
 * Reentrancy         : Non reentrant
 *
 * Parameters (in)    : None
 *
 * Parameters (inout) : None
 *
 * Parameters (out)   : None
 *
 * Return value       : return d-cache enable status
 *
 * Description        : This function use for read the d-cache status.
 *
 * \endverbatim
 * Traceability       :
 *******************************************************************************************************/
extern uint32 Mcal_ArchRdSctlr(void);
/** *****************************************************************************************************
 * \brief This function is used to clean the cache and is responsible for writing the cached dirty data
 *        back into memory.
 *
 * \verbatim
 * Syntax             : void Mcal_CleanCacheRange
 *                      (
 *                          const void *start
 *                          uint32 len
 *                      )
 *
 * Service ID[hex]    : None
 *
 * Sync/Async         : Synchronous
 *
 * Reentrancy         : Non reentrant
 *
 * Parameters (in)    : *start - Start address.
 *                      len    - Address length.
 *
 * Parameters (inout) : None
 *
 * Parameters (out)   : None
 *
 * Return value       : None
 *
 * Description        : This function is used to clean the cache and is responsible for writing the
 *                      cached dirty data back into memory.
 * \endverbatim
 * Traceability       : SWSR_DMA_047
 *******************************************************************************************************/
extern void Mcal_CleanCacheRange(const void *start, uint32 len);
/** *****************************************************************************************************
 * \brief This function is used to clean the cache and is responsible for writing the cached dirty data
 *        back into memory and read new date from memory to cache.
 *
 * \verbatim
 * Syntax             : void Mcal_CleanInvalidateCacheRange
 *                      (
 *                          const void *start
 *                          uint32 len
 *                      )
 *
 * Service ID[hex]    : None
 *
 * Sync/Async         : Synchronous
 *
 * Reentrancy         : Non reentrant
 *
 * Parameters (in)    : *start - Start address.
 *                      len    - Address length.
 *
 * Parameters (inout) : None
 *
 * Parameters (out)   : None
 *
 * Return value       : None
 *
 * Description        : This function is used to clean the cache and is responsible for writing the
 *                      cached dirty data back into memory and read new date from memory to cache.
 * \endverbatim
 * Traceability       : SWSR_DMA_047
 *******************************************************************************************************/
extern void Mcal_CleanInvalidateCacheRange(const void *start, uint32 len);
/** *****************************************************************************************************
 * \brief This function is used to clean the cache and is responsible read new date from memory to
 *        cache.
 *
 * \verbatim
 * Syntax             : void Mcal_InvalidateCacheRange
 *                      (
 *                          const void *start
 *                          uint32 len
 *                      )
 *
 * Service ID[hex]    : 0x00
 *
 * Sync/Async         : Synchronous
 *
 * Reentrancy         : Non reentrant
 *
 * Parameters (in)    : *start - Start address.
 *                      len    - Address length.
 * Parameters (inout) : None
 *
 * Parameters (out)   : None
 *
 * Return value       : None
 *
 * Description        : This function is used to clean the cache and is responsible read new date from
 *                      memory to cache.
 * \endverbatim
 * Traceability       : SWSR_MCALLIB_047
 *******************************************************************************************************/
extern void Mcal_InvalidateCacheRange(const void *start, uint32 len);

#endif /* #if !defined(ASSEMBLY) */
#endif /* #ifndef MCALLIB_ASM_H */
/* End of file */
